import { CobType } from '../types/index'
import { createElement } from './element'

const Tools = createElement({
    tagName: 'div',
    className: 'cob-tools',
    childNodes: [
        createElement({
            tagName: 'div',
            text: 'header',
            className: 'cob-tools-header'
        }),
        createElement({
            tagName: 'div',
            text: 'body',
            childNodes: []
        }),
        createElement({
            tagName: 'div',
            text: 'footer',
            className: 'cob-tools-footer'
        })
    ]
})

/**
 * 初始化
 * @param options
 */
export const Cob = (options: CobType) => {
    const defineOptions = Object.assign(options, {
        env: 'prd'
    })

    if (!defineOptions.t) {
        throw new Error('没有token')
    }

    document.body.appendChild(Tools)
}
